

def black(i):
    a = i
    while len(set(list(str(a)))) >1:
        if a == 6174:
            print(f'{i}最终变为6174')
            break
        b = sorted(list(str(a)))
        n = int("".join(b))
        b = b[::-1]
        m = int("".join(b))
        a = m - n

    else:
        print(f'{i}出现重复数字')

for i in range(1000, 10000):
    black(i)


